package com.commons.dbutils.connection;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

public class ConnectionHelper {
	private DataSource dataSource = null;
	
	public ConnectionHelper(){
		
	}
	public DataSource getDataSource() {
		return dataSource;
	}
	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}
	public Connection getConnection() throws SQLException{
		if(this.dataSource==null){
			throw new SQLException("dataSource is null.");
		}
		return this.dataSource.getConnection();
	}
	
	public void release(Connection conn) throws SQLException {
		if (conn != null){
			conn.close();
		}
	}
	
}
